package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SafeguardSafe;
import com.ruoyi.system.service.ISafeguardSafeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 保障文本域详情Controller
 *
 * @author ruoyi
 * @date 2021-05-20
 */
@RestController
@RequestMapping("/guanyu/safe")
public class SafeguardSafeController extends BaseController
{
    @Autowired
    private ISafeguardSafeService safeguardSafeService;

    /**
     * 查询保障文本域详情列表
     */

    @GetMapping("/list")
    public TableDataInfo list(SafeguardSafe safeguardSafe)
    {
        startPage();
        List<SafeguardSafe> list = safeguardSafeService.selectSafeguardSafeList(safeguardSafe);
        return getDataTable(list);
    }

    /**
     * 导出保障文本域详情列表
     */

    @GetMapping("/export")
    public AjaxResult export(SafeguardSafe safeguardSafe)
    {
        List<SafeguardSafe> list = safeguardSafeService.selectSafeguardSafeList(safeguardSafe);
        ExcelUtil<SafeguardSafe> util = new ExcelUtil<SafeguardSafe>(SafeguardSafe.class);
        return util.exportExcel(list, "safe");
    }

    /**
     * 获取保障文本域详情详细信息
     */

    @GetMapping(value = "/{safeId}")
    public AjaxResult getInfo(@PathVariable("safeId") Long safeId)
    {
        return AjaxResult.success(safeguardSafeService.selectSafeguardSafeById(safeId));
    }

    /**
     * 新增保障文本域详情
     */

    @PostMapping
    public AjaxResult add(@RequestBody SafeguardSafe safeguardSafe)
    {
        return toAjax(safeguardSafeService.insertSafeguardSafe(safeguardSafe));
    }

    /**
     * 修改保障文本域详情
     */

    @PutMapping
    public AjaxResult edit(@RequestBody SafeguardSafe safeguardSafe)
    {
        return toAjax(safeguardSafeService.updateSafeguardSafe(safeguardSafe));
    }

    /**
     * 删除保障文本域详情
     */

    @DeleteMapping("/{safeIds}")
    public AjaxResult remove(@PathVariable Long[] safeIds)
    {
        return toAjax(safeguardSafeService.deleteSafeguardSafeByIds(safeIds));
    }
}